import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsEnum, IsNotEmpty, IsNumber, Min } from "class-validator";
import { PageDto } from "src/common/dto/dto";
import { Status, JumpType } from "src/dictionaries/index.enum";

export class GetBannerDto extends PageDto {
    /** 是否启用 */
    @ApiPropertyOptional({
        name: 'status',
        description: '是否启用',
        enum: Status,
    })
    public readonly status: Status;
    /** 跳转类型 */
    @ApiPropertyOptional({
        name: 'jumpType',
        description: '跳转类型',
        enum: JumpType,
    })
    public readonly jumpType: JumpType;
    /** 语言 */
    @ApiPropertyOptional({
        type: String,
        name: 'lang',
        description: '语言',
    })
    public readonly lang?: string;
}
export class CreateBannerDto {
    /** 图片 */
    @IsNotEmpty({ message: '图片不能为空' })
    @ApiProperty({
        type: String,
        name: 'img',
        description: '图片',
    })
    public readonly img: string;
    /** 是否启用 */
    @IsEnum(Status)
    @IsNotEmpty({ message: '状态不能为空' })
    @ApiProperty({
        name: 'status',
        description: '是否启用',
        enum: Status,
    })
    public readonly status: Status;
    /** 语言 */
    @IsNotEmpty({ message: '语言不能为空' })
    @ApiProperty({
        type: String,
        name: 'lang',
        description: '语言',
    })
    public readonly lang?: string;
    /** 跳转类型 */
    @IsEnum(JumpType)
    @IsNotEmpty({ message: '跳转类型不能为空' })
    @ApiProperty({
        name: 'jumpType',
        description: '跳转类型',
        enum: JumpType,
    })
    public readonly jumpType: JumpType;
    /** 跳转链接 */
    @ApiPropertyOptional({
        type: String,
        name: 'url',
        description: '跳转链接',
    })
    public readonly url?: string;
    /** 备注 */
    @ApiPropertyOptional({
        type: String,
        name: 'remarks',
        description: '备注',
    })
    public readonly remarks?: string;

    /** 排序 */
    @IsNotEmpty({ message: '排序不能为空' })
    @IsNumber()
    @Min(0, {
        message: '排序不能小于0'
    })
    @ApiProperty({
        type: Number,
        name: 'sort',
        description: '排序',
    })
    public readonly sort?: number;

    /** 电影ID */
    @ApiPropertyOptional({
        type: Number,
        name: 'moviesId',
        description: '电影ID',
    })
    public readonly moviesId?: number;
}
export class UpdateBannerDto extends CreateBannerDto {
    @IsNotEmpty({ message: 'id不能为空' })
    @ApiProperty({
        type: Number,
        name: 'id',
        description: 'id',
    })
    public readonly id: number;
}
